﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Manage/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<RuiJing.Web.Areas.Manage.Models.ImagesModels.IndexModel>" %>
<%@ Import Namespace="System.IO" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	图片管理
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<% Html.BeginForm("index", "images", new { id = "flieform" }, new { Model.ID, Model.A, Model.B }); %>
    <% var r = Server.MapPath(Model.ServerPath); %>
    <% Action<DirectoryInfo> a = null; a = (p) => %>
    <% { %>
        <% if (Model.Root.FullName.Contains(p.FullName)) %>
        <% { %>
        <%=Html.ActionLink("图片管理:", "index")%>
        <% } %>
        <% else %>
        <% { %>
        <% a(p.Parent); %>-&gt;
        <%=Html.ActionLink(p.Name, "index", new { ID = p.FullName.Remove(0, r.Length) }) %>
        <% } %>
    <% }; %>
<div class="typepath">
<% a(Model.Current); %>
</div>
<div class="typechilds">
    <ul>
        <% foreach (var item in Model.Current.GetDirectories()) %>
        <% { %>
        <li><%=Html.ActionLink(item.Name, "index", new { ID = item.FullName.Remove(0, r.Length) })%></li>
        <% } %>
    </ul>
</div>
<div class="filetop">
<table width="100%">
    <tr>
        <td align="left"><a href="javascript:;" onclick="upFile()">上传图片</a></td>
        <td><label><input type="checkbox" onclick="chooseID(this)" />选中所有</label></td>
        <td><input type="submit" name="DelMore" value="删除选中" onclick="if($('.filelist #name:checked').length==0) { alert('请先选中要删除的图片！') ; return false; }" /></td>
    </tr>
</table>
</div>
<div class="filelist">
    <% foreach (var item in Model.Items) %>
    <% { %>
    <div class="picitem">  
        <div class="picimg" title="<%=string.Format("文 件 名：{0}\r\n上传时间：{1}", item.Name, item.LastWriteTime) %>">
        <a href='<%=Url.Content(Model.ServerPath + item.FullName.Remove(0, r.Length)) %>' target="_blank">
            <img class="img" src='<%=Url.Content(Model.ServerPath + item.FullName.Remove(0, r.Length)) %>' alt='' />
        </a>
        </div>
        <div class="picname">
        <input type="checkbox" id="name" name="name" value='<%=item.Name %>' />
        <%=Html.ActionLink("删除", "index", new { ID = Model.ID, Model.A, Model.B, item.Name ,DelMore=true }, new { onclick = "return confirm('您确定要删除该图片吗？');" })%>
        </div>
    </div> 
    <% } %>
    <% if (Model.SumCount > 0) %>
    <% { %>
    <div class="pager">
        <%=Html.Pager(Model.B, Model.B, 18, Model.SumCount, "a", Url.Route(new { Model.ID }), "b")%>
    </div>
    <% } %>
    <input type="hidden" id="btnAction" name="" />
</div>
<% Html.EndForm(); %>
<div id="adddir">
    <form method="post" enctype="multipart/form-data" action='<%=Url.Action("index", new { Model.ID, Model.A, Model.B })  %>' id="UpFile">
        <table width="80%" height="auto" id="filetable">
            <tr>
                <td width="100px" align="right">选择图片： </td>
                <td align="left"><input type="file" name="FileName" id="FileName" class="FileName" /></td>
            </tr>
        </table>
        <input type="hidden" name="UpFile" id="UpFile" value="True" />
    </form>
</div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="StypeAndScript" runat="server">
    <script src='<%=Url.Content("~/Scripts/tool/trre-view.js") %>' type="text/javascript"></script>
    <link href='<%=Url.Content("~/Scripts/tool/ui.css") %>'  rel="stylesheet" type="text/css" />
    <style type="text/css">
    .typepath{ width:100%; line-height:30px; }
    .filetop{ width:100%; line-height:30px;}
    .typechilds { border-bottom:1px solid #888;}
    .typechilds,.typechilds ul{ height:auto; overflow:hidden; width:100%; }
    .typechilds li{ height:25px; padding:3px 5px; width:100px; text-align:center; float:left;}
    .filelist{width:100%; height:auto; overflow:hidden;}
    .pager{ width:100%; float:left; text-align:center;}
    .trre-content{border:1px solid #c3c3c3; margin:10px;padding:10px;line-height:25px;}
    .trre-set{width:500px;}
    .dialog,#adddir{ display:none;}
</style>
    <script type="text/javascript">
        function chooseID(c) {
            $('.filelist #name').each(function () {
                this.checked = c.checked;
            });
        }

        function upFile() { 
            $.blockUI({ message: null });
            var g =
            {
                closeText: '取消',
                title: '上传图片',
                width: '400px',
                height: 'auto',
                beforeClose: function () {
                    $.unblockUI();
                },
                buttons: {
                    "取消": function () {
                        $(this).dialog('close');
                    },
                    "确定": function () {
                        var val = $(".FileName");
                        var flag = true;
                        val.each(function (i) {
                            if (this.value.length == 0) {
                                flag = false;
                                return false;
                            }
                            $(this).attr("name", "upfile" + i);
                        });
                        if (!flag) {
                            alert("请选择图片!");
                            return;
                        }
                        $("#UpFile").submit();
                        $(this).dialog('close');
                    },
                    "添加": function () {
                        var str = '' +
'            <tr>' +
'                <td width="100px" align="right">选择图片： </td>' +
'                <td align="left"><input type="file" class="FileName"/></td>' +
'            </tr>'
                        $(str).appendTo($('#filetable'));
                    }
                }
            };
            $("#adddir").dialog(g);
        }

    </script>
</asp:Content>
